/*
========================================================================
 Name        : CallDetailTrackerAppUi.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : 
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <eikmenub.h>
#include <akncontext.h>
#include <akntitle.h>
#include <CallDetailTracker.rsg>
// ]]] end generated region [Generated System Includes]

// [[[ begin generated region: do not modify [Generated User Includes]
#include "CallDetailTrackerAppUi.h"
#include "CallDetailTracker.hrh"
#include "CallDetailTrackerMainForm.hrh"
#include "CallDetailTrackerViewReportOptionsForm.hrh"
#include "CallDetailTrackerGenerateReportForm.hrh"
#include "CallDetailTrackerProgressingForm.hrh"
#include "CallDetailTrackerMainFormView.h"
#include "CallDetailTrackerViewReportOptionsFormView.h"
#include "CallDetailTrackerGenerateReportFormView.h"
#include "CallDetailTrackerManualTransferFormView.h"
#include "CallDetailTrackerProgressingFormView.h"
#include "CallDetailTrackerDeleteCallLogSelectorView.h"
#include "CallDetailTrackerMainControlerView.h"
// ]]] end generated region [Generated User Includes]

#include "SplashScreen.h"
#include "Log_Monitor.h"

// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]

/**
 * Construct the CCallDetailTrackerAppUi instance
 */ 
CCallDetailTrackerAppUi::CCallDetailTrackerAppUi()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}

/** 
 * The appui's destructor removes the container from the control
 * stack and destroys it.
 */
CCallDetailTrackerAppUi::~CCallDetailTrackerAppUi()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}

/*
CSplashScreen* iSplashScreen = CSplashScreen::NewL();
User::After(2000000);	// check this
iSplashScreen->~CSplashScreen();
 */
// [[[ begin generated function: do not modify
void CCallDetailTrackerAppUi::InitializeContainersL()
	{
	iCallDetailTrackerMainFormView = CCallDetailTrackerMainFormView::NewL();
	AddViewL( iCallDetailTrackerMainFormView );
	SetDefaultViewL( *iCallDetailTrackerMainFormView );
	iCallDetailTrackerViewReportOptionsFormView = CCallDetailTrackerViewReportOptionsFormView::NewL();
	AddViewL( iCallDetailTrackerViewReportOptionsFormView );
	iCallDetailTrackerGenerateReportFormView = CCallDetailTrackerGenerateReportFormView::NewL();
	AddViewL( iCallDetailTrackerGenerateReportFormView );
	iCallDetailTrackerManualTransferFormView = CCallDetailTrackerManualTransferFormView::NewL();
	AddViewL( iCallDetailTrackerManualTransferFormView );
	iCallDetailTrackerProgressingFormView = CCallDetailTrackerProgressingFormView::NewL();
	AddViewL( iCallDetailTrackerProgressingFormView );
	iCallDetailTrackerDeleteCallLogSelectorView = CCallDetailTrackerDeleteCallLogSelectorView::NewL();
	AddViewL( iCallDetailTrackerDeleteCallLogSelectorView );
	iCallDetailTrackerMainControlerView = CCallDetailTrackerMainControlerView::NewL();
	AddViewL( iCallDetailTrackerMainControlerView );
	}
// ]]] end generated function

/**
 * Handle a command for this appui (override)
 * @param aCommand command id to be handled
 */
void CCallDetailTrackerAppUi::HandleCommandL( TInt aCommand )
	{
	// [[[ begin generated region: do not modify [Generated Code]
	TBool commandHandled = EFalse;
	switch ( aCommand )
		{ // code to dispatch to the AppUi's menu and CBA commands is generated here
	
		case EAknSoftkeyExit:
			commandHandled = HandleControlPaneRightSoftKeyPressedL( aCommand );
			break;
		default:
			break;
		}
	
		
	if ( !commandHandled ) 
		{
		if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit )
			{
			Exit();
			}
		}
	// ]]] end generated region [Generated Code]
	
	}

/** 
 * Override of the HandleResourceChangeL virtual function
 */
void CCallDetailTrackerAppUi::HandleResourceChangeL( TInt aType )
	{
	CAknViewAppUi::HandleResourceChangeL( aType );
	// [[[ begin generated region: do not modify [Generated Code]
	// ]]] end generated region [Generated Code]
	
	}
				
/** 
 * Override of the HandleKeyEventL virtual function
 * @return EKeyWasConsumed if event was handled, EKeyWasNotConsumed if not
 * @param aKeyEvent 
 * @param aType 
 */
TKeyResponse CCallDetailTrackerAppUi::HandleKeyEventL(
		const TKeyEvent& aKeyEvent,
		TEventCode aType )
	{
	// The inherited HandleKeyEventL is private and cannot be called
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	return EKeyWasNotConsumed;
	}

/** 
 * Override of the HandleViewDeactivation virtual function
 *
 * @param aViewIdToBeDeactivated 
 * @param aNewlyActivatedViewId 
 */
void CCallDetailTrackerAppUi::HandleViewDeactivation( 
		const TVwsViewId& aViewIdToBeDeactivated, 
		const TVwsViewId& aNewlyActivatedViewId )
	{
	CAknViewAppUi::HandleViewDeactivation( 
			aViewIdToBeDeactivated, 
			aNewlyActivatedViewId );
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}

/**
 * @brief Completes the second phase of Symbian object construction. 
 * Put initialization code that could leave here. 
 */ 
void CCallDetailTrackerAppUi::ConstructL()
	{		
	// [[[ begin generated region: do not modify [Generated Contents]
	
	BaseConstructL( EAknEnableSkin ); 
	InitializeContainersL();
	// ]]] end generated region [Generated Contents]
	
	// displaying the Splash screen at application startup
	CSplashScreen* iSplashScreen = CSplashScreen::NewL();
	iSplashScreen->~CSplashScreen();
	User::After(2000000);	
	
	// initializing LogMonitor
	mMonitor = new (ELeave) MLogMonitor;
	cMonitor = CLogMonitor::NewL(mMonitor);	
	
	}

/** 
 * Handle the rightSoftKeyPressed event.
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CCallDetailTrackerAppUi::HandleControlPaneRightSoftKeyPressedL( TInt aCommand )
	{
	// TODO: implement rightSoftKeyPressed event handler
	return EFalse;
	}
				
